    /* global FormData visitUrl*/
    /* global getCookie */
    /* global template */
    $("#area-choise").cityPicker({
        title: "选择城市",
        onChange: function (picker, values, displayValues) {
          var name = displayValues[0] + " " + displayValues[1] + " " + displayValues[2];
          $("#area").val(name);
        }
      });
    function puilcPro(){
        var id = $("#adreeId").val();
        var name = $("#name").val();
        var area = $("#area").val();
        var address = $("#address").val();
        var phone = $("#phone").val();
       
        if (name == ''){
            $.toast("名称不能为空", "cancel");
            return;
        }
        if (area == ''){
            $.toast("城市不能为空", "cancel");
            return;
        }
        if (address == ''){
            $.toast("地址不能为空", "cancel");
            return;
        }
        if (phone == ''){
            $.toast("电话不能为空", "cancel");
            return;
        }
       
        var params = {};
        params.id = id;
        params.name = name;
        params.areaNames = area;
        params.address = address;
        params.phone = phone;
        params.token = getCookie('token');
 
        if (id){
            upPro(params);
           } else {
            addPro(params);
           }
    } 

    function addPro(params){
        delete params.id;
        $.ajax({
            type:'POST',
            url:"/antique/api/userAddress/add_address",
            data: params,
            dataType:"json",
            success:function(res){
                if (res.code == 0){
                    visitUrl('/receive_address',true);
                    $.toast("成功");
                 } else {
                    $.toast(res.message, "cancel");
                }
                
            }
        });
    }
    function upPro(params){
        $.ajax({
            type:'POST',
            url:"/antique/api/userAddress/update_address",
            data: params,
            dataType:"json",
            success:function(res){
                if (res.code == 0){
                    visitUrl('/receive_address',true);
                    $.toast("成功");
                 } else {
                    $.toast(res.message, "cancel");
                }
                
            }
        });
    }


